<%-- 
    Document   : index
    Created on : May 4, 2011, 8:47:16 AM
    Author     : Huynh Ngoc Tin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import = "uit.tkorg.coauthorgraph.dto.PaperDTO"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
   
<%	ArrayList publicationList = (ArrayList) session.getAttribute("publicationList");
	String actionResult = (String) request.getAttribute("actionResult");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CrawlFromMAS</title>
<script language="javascript">
function toogleAll() {
    importCheckBoxes = document.publicationForm.importStatusCheckBox;
    for (i = 0; i < importCheckBoxes.length; i++){
        if (importCheckBoxes[i].checked == true)
            importCheckBoxes[i].checked = false;
        else importCheckBoxes[i].checked = true;
    }
}

function onImportClick() {
    importCheckBoxes = document.publicationForm.importStatusCheckBox;
    var strTemp = "";
    for (i = 0; i < importCheckBoxes.length; i++){
        if (importCheckBoxes[i].checked == true) {
            strTemp += i + "#";
        }
    }
    document.publicationForm.selectedPaperListStr.value = strTemp;
    document.publicationForm.action = "./ImportPublicationServlet";
    document.publicationForm.submit();

}
</script>    
    
</head>
<body>
<center><h1><font>Crawl From Microsoft Academic Search</font></h1></center>
<a href="./GoIndexPageServlet">Home</a>&nbsp;&nbsp;&nbsp;
<a href="./GoBibliographyDBBuildingServlet">Build & Enrich CS Publications Bibliography DB</a>&nbsp;&nbsp;&nbsp;
<a href="./GoCoAuthorGraphBuildingServlet">Build Co-Author Network</a>&nbsp;&nbsp;&nbsp;
<a href="#">Computer Science Publications Search</a>&nbsp;&nbsp;&nbsp;
<hr width="100%" size=10 color="#EBEBEB"> 
<form name="ManualCrawlForm" action="./MASManualCrawlingServlet" method="post">
    <table>
        <tr>
            <td>Author Name:</td>
            <td>
                    <input type="text" name="authorName">
            </td>
            <td></td>
            <td><input type="submit" value="Crawl"></td>
        </tr>
    </table>
</form>
<hr width="100%" size=10 color="#EBEBEB">
<form action="" name="publicationForm">
<input type="hidden" name="selectedPaperListStr" value="">
    <div align="left">
        <b><font color="Black">Publications:</font></b>
        <%  if (actionResult != null) {
        %>
            <b><font color="red"><%=actionResult%></font></b>
        <%
            }
        %>
    </div>
    <div align="right"><a href="javascript:toogleAll()">Toggle all</a></div>
    <table bordercolor="blue" border="1" width="100%">
        <tr bgcolor="#EBEBEB">
            <td width="2%"><b>No.</b></td>
            <td width="27%"><b>Title</b></td>
            <td width="20%"><b>Authors</b></td>
            <td width="15%"><b>Conference</b></td>
            <td width="15%"><b>Journal</b></td>
            <td width="10%"><b>Pages</b></td>
            <td width="4%"><b>Year</b></td>
            <td width="4%"><b>Update</b></td>
            <td width="3%"></td>
        </tr>
<%
        if (publicationList != null) {
            for (int i=0; i<publicationList.size(); i++) {
                PaperDTO paperDTO = (PaperDTO) publicationList.get(i);
%>
        <tr>
            <td><%=i%></td>
            <td><%=paperDTO.getTitle()%></td>
            <td>
            <% for (int j=0; j<paperDTO.getAuthorNameList().size(); j++) {
            %><%=paperDTO.getAuthorNameList().get(j)%>;
            <%}
            %>
            </td>
            <td>
                <%if ((paperDTO.getConferenceName() != null) && (!paperDTO.getConferenceName().equalsIgnoreCase(""))) {%>
                        <%=paperDTO.getConferenceName()%>
                <%} %>
            </td>
            <td>
                <%if ((paperDTO.getJournalName() != null) && (!paperDTO.getJournalName().equalsIgnoreCase(""))) {%>
                        <%=paperDTO.getJournalName()%>
                <%} %>
            </td>
            <td><%=paperDTO.getPages()%></td>
            <td><%=paperDTO.getYear()%></td>
            <td><a href="#">Edit</a></td>
            <td width="3%"><input type="checkbox" name="importStatusCheckBox" value="<%=i%>"></td>
        </tr>
<%
                    }
            }
%>
    </table>
    <hr width="100%" size=10 color="#EBEBEB">
        <div align="right">
        <input type="button" value="Check existing in the local DB" name="checkExistBtn">
        <input type="button" value="Import into the Database" name="importBtn" onclick="onImportClick();">
    </div>
</form>
</body>
</html>
